package com.bonc.event.model;

import java.util.Vector;

import com.bonc.utilities.Span;

/**
 * @author donggui@bonc.com.cn
 * @version 2016 2016年6月28日 上午10:48:02
 */
public class BONCEventMention {
	
	public String id;
	/**
	 *  the extent of the mention, with start and end positions based on
	 *  ACE offsets (excluding XML tags).
	 */
	public Span extent;
	/**
	 *  the text of the extent.
	 */
	public String text;
	
	/**
	 * Qi: indices of head tokens in the sentence
	 */
	public Vector<Integer> headIndices;
	public Vector<Integer> extentIndices;
	
	public BONCEvent event;
	
	public BONCEventMention(){
		
	}
	
	/**
	 * calculate the indice of each head token accodring to span of 
	 * token in this sentence. For Value/Timex, this corrresponds to extent, for Entity, this corresponds to head
	 * @param tokenSpans
	 */
	public void setExtentIndices(Span[] tokenSpans)
	{
		if(extentIndices == null)
		{
			extentIndices = new Vector<Integer>();
			int i = 0;
			for(Span tokenSpan : tokenSpans)
			{
				if(this.extent.overlap(tokenSpan))
				{
					extentIndices.add(i);
				}
				i++;
			}
		}
	}
	
	/**
	 * calculate the indice of each head token accodring to span of 
	 * token in this sentence. For Value/Timex, this corrresponds to extent, for Entity, this corresponds to head
	 * @param tokenSpans
	 */
	public void setHeadIndices(Span[] tokenSpans)
	{
		if(headIndices == null && extentIndices == null)
		{
			setExtentIndices(tokenSpans);
		}
		headIndices = extentIndices;
	}
	
	public String getType()
	{
		return event.getText();
	}

	public String getHeadText () {
		return text;
	}
}
